import { AxiosRequestConfig, AxiosResponse } from 'axios'
export interface YcRequestInterceptors<T = AxiosResponse> {
  // 请求成功拦截接口
  requestInterceptor?: (config: AxiosRequestConfig) => AxiosRequestConfig
  requestInterceptorCatch?: (error: any) => any

  // 响应拦截接口
  // responseInterceptor?: (config: AxiosResponse) => AxiosResponse
  responseInterceptor?: (res: T) => T
  responseInterceptorCatch?: (error: any) => any
}

export interface YcRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  // 扩展config 是为了让options中能传入interceptors（拦截器）
  interceptors?: YcRequestInterceptors<T>
  showLoading?: boolean
}

export interface errorResponse {
  data: string
  status: number
}
